window: Only update the inspector once
authorBenjamin Otte <otte@redhat.com>
Tue, 25 Aug 2015 17:46:09 +0000 (19:46 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 26 Aug 2015 13:46:07 +0000 (15:46 +0200)
Instead of queueing a new idle handler every time we call
gtk_window_update_debugging(), only queue one if none is queued that.

Saves a lot of work, in particular when templates create context menus
for every row in a large listbox as in the gtk-demo listbox example.

gtk/gtkwindow.c

index 0367c90a9e144dad278de1a3e34af99962df56fe..126f8f99d592d3ca427ba2b8ae2d9a31d47e89c2 100644 (file)
@@ -12051,21 +12051,24 @@ warn_response (GtkDialog *dialog,
     }
 }
 
+static guint gtk_window_update_debugging_id;
+
 static gboolean
 update_debugging (gpointer data)
 {
   gtk_inspector_window_rescan (inspector_window);
+  gtk_window_update_debugging_id = 0;
   return G_SOURCE_REMOVE;
 }
 
 static void
 gtk_window_update_debugging (void)
 {
-  if (inspector_window)
+  if (inspector_window &&
+      gtk_window_update_debugging_id == 0)
     {
-      guint id;
-      id = gdk_threads_add_idle (update_debugging, NULL);
-      g_source_set_name_by_id (id, "[gtk+] gtk_window_update_debugging");
+      gtk_window_update_debugging_id = gdk_threads_add_idle (update_debugging, NULL);
+      g_source_set_name_by_id (gtk_window_update_debugging_id, "[gtk+] gtk_window_update_debugging");
     }
 }